package com.daohang361.imqq.decoder;

import com.daohang361.imqq.Asycore.QQUser;
import com.daohang361.imqq.tool.Hex2Bytes;
import com.daohang361.imqq.tool.MyByteReciveArray;

public abstract class AbstractDecoder implements InterfaceDecoder {
	public MyByteReciveArray myArray;
	public QQUser sessionQQ;
	public byte[] decryptAll=null;
	@Override
	public void init(MyByteReciveArray myArray, QQUser sessionQQ) {
		this.myArray=myArray;
		this.sessionQQ=sessionQQ;
	}

	@Override
	public QQUser decode() throws Exception {
			myArray.decryptRemain(sessionQQ.getAttr("SessionKey"));
			decryptAll=myArray.extractAll();
		System.out.println(Integer.toHexString(myArray.getCommand())+":"+Hex2Bytes.bytesToHexString(decryptAll));
		violence();
			sessionQQ.setLogintimes(sessionQQ.getLogintimes()+1);//登陆包前进
			sessionQQ.setPakage(sessionQQ.getPakage()+1);//登陆包自动增长
			return sessionQQ;
	}
	/**
	 * 暴力打印
	 */
	public void violence()
	{
		//new ViolenceBytes(decryptAll).violence();
	}

	@Override
	public Object invoke(Object... o) {
		// TODO Auto-generated method stub
		return null;
	}
}
